#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>



#define FILE_NAME "mybite.txt"

int main()
{
    FILE* fp = fopen(FILE_NAME,"w+");

    if(fp == NULL)
    {
        perror("fopen");
        exit(-1);
    }
    fseek(fp, 0, SEEK_SET);
    char str[] = "linux so easy!\n";
    size_t num = strlen(str);
    size_t ret = fwrite(str,sizeof(char),num,fp);
    if(ret != num)
    {
        perror("fwrite");
        exit(-1);
    }
    fseek(fp, 0, SEEK_SET);
    char strs[101] = {0};

    ret = fread(strs,sizeof(char),num,fp);
    if(ret != num)
    {
        perror("fread");
        exit(-1);
    }
    printf("%s",strs);


    fclose(fp);
    return 0;
}

